import React, {useEffect, useState} from 'react';
import axios from "axios";
import {useNavigate, useParams} from "react-router-dom";

function UserDetails(props) {
    const {id} = useParams();
    const [info,setInfo] = useState({});
    const navigate = useNavigate();
    useEffect(()=>{
        axios.get("http://zhangpeiyue.com/scoreList/"+id).then(({data})=>{
            setInfo(data);
        })
    },[])
    return (
        <div>
            <button onClick={()=>{
                navigate(-1)
            }}>返回</button>
            <h3>{info.userName}详情</h3>
            <p>年龄：{info.age}</p>
            <p>性别：{info.sex}</p>
        </div>
    );
}

export default UserDetails;